<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5.4 素数</title>
</head>

<body>
    <script>
        var nb = 0
        for (var i = 100; i <= 1000; i++) {
            if (isPrime(i)) {
                nb += 1;
                document.write(i + ' ')
                if (nb % 6 == 0) {
                    document.write('<br>')
                }
            }
        }

        function isPrime(n) {
            if(n<1) return false;
            for (var j = 2; j < n; j++) {
                if (n % j == 0) {
                    return false;
                }              
            }
            return true;
        }
        console.log(isPrime(121)); 
    </script>
</body>

</html>